<template>
	<div class="page-wrap">
		<div class="page-content p-0">
			<div class="page-column p-0">
				<!-- 表格搜索区域 -->
				<div class="search-box">
					<div class="search-left">
						<el-button
							type="primary"
							class="m-r-12"
							size="medium"
							icon="el-icon-circle-plus"
							@click="addFun"
						>新增</el-button>
					</div>
				</div>
				<div class="table-box">
					<el-table  height="100%" v-loading="loading" :data="tableData.columnData">
						<el-table-column prop="aizheng_id" label="癌症编号" align="center"></el-table-column>
						<!-- <el-table-column prop="aizheng_type" label="癌症分类" align="center"></el-table-column> -->
						<el-table-column prop="aizheng_ename" label="癌症英文名" align="center"></el-table-column>
						<el-table-column prop="aizheng_cname" label="癌症中文名" align="center"></el-table-column>
						<el-table-column prop="qiguan_ename" label="对应器官英文名" align="center"></el-table-column>
						<el-table-column prop="qiguan_cname" label="对应器官中文名" align="center"></el-table-column>
						<el-table-column prop="ACSUSC" label="ACSUSC" align="center"></el-table-column>
						<el-table-column prop="DOSEFA" label="DOSEFA" align="center"></el-table-column>
						<el-table-column prop="DOSEFB" label="DOSEFB" align="center"></el-table-column>
						<el-table-column prop="CFRISK" label="CFRISK" align="center"></el-table-column>
						<el-table-column prop="CIRISK" label="CIRISK" align="center"></el-table-column>
						<el-table-column prop="DDREFA" label="DDREFA" align="center"></el-table-column>

						<el-table-column label="操作" align="center" width="200" fixed="right">
							<template slot-scope="scope">
								<el-button type="text" @click="addFun(scope.row)">编辑</el-button>
								<el-button type="text" class="warning" @click="deleteFun(scope.row.aizheng_id)">删除</el-button>
							</template>
						</el-table-column>
					</el-table>
				</div>
				<!-- 表格分页区域 -->
				<!-- <div class="pagination">
					<el-pagination
						:page-sizes="[5, 10, 15, 30, 50]"
						:page-size="tableData.pageSize"
						layout="sizes,total,prev,pager,next"
						:total="tableData.total"
						:current-page="tableData.currentPage"
						@size-change="handleSizeChange"
						@current-change="handleCurrentChange"
					></el-pagination>
				</div> -->
			</div>
		</div>
		<!-- 表格相关操作组件区域 -->
		<tempAdd ref="add" @refresh="tableDataInit"></tempAdd>
	</div>
</template>

<script>
import advanceQuery from "@/components/advanceQuery"
import commCheckbox from "@/components/commCheckbox"
import textLength from "@/components/textLength"
import selectPara from "@/components/selectPara"
import { mapState } from "vuex"
import tempAdd from "./tempAdd"
import { SS_AIZHENG_SEARCH, SS_AIZHENG_DELETE } from "@/service/hd5.js"

export default {
	name: "tempList",
	components: {
		advanceQuery,
		tempAdd,
		commCheckbox,
		textLength,
		selectPara,
	},
	data() {
		return {
			tableData: {
				// 表格绑定对象
				orders: "",
				columns: "",
				pageSize: 15,
				currentPage: 1,
				total: 0,
				columnData: [],
			},
			loading: false,
			show: false,
		}
	},
	created() {
		this.tableDataInit()
	},
	computed: {
		...mapState({
			token: (state) => state.token.token,
		}),
	},
	methods: {
		addFun(row) {
			this.$refs.add.showLayout(row)
		},
		tableDataInit() {
			// 列表数据请求
			let params = {}
			this.loading = true
			this.$appApi
				.SS_AIZHENG_SEARCH(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求数据失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						this.loading = false
						this.tableData.columnData = JSON.parse(
							res.data.substring(8)
						)
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
		handleCurrentChange(val) {
			// 分页方法 （点击第val页触发）
			this.tableData.currentPage = val
			this.tableDataInit()
		},
		handleSizeChange(val) {
			// 分页方法 （改变每页val条触发）
			this.tableData.pageSize = val
			this.tableDataInit()
		},
		resetForm() {
			// 重置按钮
			this.$refs.searchForm.resetFields()
			this.tableDataInit()
		},
		deleteFun(ids) {
			// 单选删除

			let confirmMsg = "确认删除选中数据？删除后将不能恢复！"
			this.$confirm(confirmMsg, {
				type: "warning",
				title: "提示",
			})
				.then(() => {
					let params = {
						aizheng_id: ids,
					}
					this.$appApi
						.SS_AIZHENG_DELETE(params)
						.then((res) => {
							var str = res.data.substring(0, 1)
							if (str == "E") {
								let message = res.data.substring(6)
								this.$notify.error({
									title: "请求数据失败！",
									message: message,
									type: "success",
								})
							} else if (str == "S") {
								this.$notify({
									title: "提示",
									type: "success",
									message: "删除成功",
								})
								this.tableDataInit()
							}
						})
						.catch((err) => {
							console.log(err)
						})
				})
				.catch(() => {})
		},
	},
}
</script>